package com.renjiyue.dao;

import com.renjiyue.pojo.Student;
import com.renjiyue.pojo.Teacher;
import com.renjiyue.utils.Mybatisutils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class testGetStudents {
    @Test
    public void testGetStudents1(){
        SqlSession session = Mybatisutils.getSqlSession();
        TeacherMapper mapper = session.getMapper(TeacherMapper.class);
        Teacher teacher = mapper.getteacher(1);
        System.out.println(teacher);
        session.close();
    }
    @Test
    //查询嵌套
    public void testStudent(){
        SqlSession sqlSession = Mybatisutils.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        for (Student student : mapper.getStudent()) {
            System.out.println(student);
        }
        sqlSession.close();
    }
    //结果嵌套处理
    @Test
    public void testGetStudent2(){
        SqlSession session = Mybatisutils.getSqlSession();
        StudentMapper mapper = session.getMapper(StudentMapper.class);
        List<Student> student2 = mapper.getStudent2();
        System.out.println(student2);
        session.close();
    }
}
